#include <allegro.h>
#include <stdio.h>
#include "fct.h"



/*
 * module background
 */

BITMAP* load_background_bmp(char chemin_background[])
{
	BITMAP* Background;

	Background=load_bitmap(chemin_background, NULL);
	if(Background == NULL){
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Unable to load image !\n%s\n", allegro_error);
		return (NULL);
	}
	return (Background);

}





void draw_background(BITMAP *Background,BITMAP*Buffer)
{
	blit(Background, Buffer, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
}

void destroy_background(BITMAP * Background)
{
	destroy_bitmap(Background);
}


void load_Rebecca(Rebecca *R)
{
//int i;
//char tmp[60];
	R->img_bravo=load_bitmap("bravo.bmp", NULL);
	R->img_erreur=load_bitmap("erreur.bmp", NULL);
        R->img_perdu=load_bitmap("perdu.bmp", NULL);

	if ((R->img_bravo == NULL) || (R->img_erreur == NULL) || (R->img_perdu == NULL) )
        {
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Unable to load image !\n%s\n", allegro_error);
		
	}	
	

}

void init_Rebecca(Rebecca *R)
{
	
	R->x =500 ;
	R->y =250 ;
}



void destroy_Rebecca(Rebecca *R)
{
	//int i;
		destroy_bitmap(R->img_bravo);
		destroy_bitmap(R->img_erreur);
                destroy_bitmap(R->img_perdu);

}

// MODULE REBECCA BONUS //
void draw_Rebecca_bonus (Rebecca *R,BITMAP *Buffer, int indice)
{
if (indice ==0)
{
	draw_sprite(Buffer, R->img_bravo,R->x, R->y);
}
if (indice ==1)
{
	draw_sprite(Buffer, R->img_erreur,R->x, R->y);
}
if(indice ==2)
{
	draw_sprite(Buffer, R->img_perdu,R->x, R->y);
}

}

//selon la reponse du jeu//
void affiche_Rebecca_bonus(Rebecca *R,int *rep ,BITMAP * Background)
{
if (*rep==0) {
     draw_Rebecca_bonus(R,Background,0);
}else if (*rep==1) {
     draw_Rebecca_bonus(R,Background,1);
}
else if (*rep==2) {
     draw_Rebecca_bonus(R,Background,2);
}
}

// MODULE REBECCA STAGE selon int main du jeu//

void draw_rebecca_stage( Rebecca *R, BITMAP *Buffer, int *stage)
{
	if ((*stage)==3)
	{
	draw_sprite(Buffer, R->img_kid,500, 400);
        }
}
/*
// INCOMPLET selon pirate//
//void depl_alea (Pirate *P, Rebecca *R, BITMAP *Background)
{
//R->x -=  (vitesse) ;

//P->x -= (vitesse) ;
}
*/

